home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / xeno / megacd.lha / megacd / Search.rexx < prev   
OS/2 REXX Batch file  |  1995-10-01  |  5KB  |  194 lines

  1. /*
  2.  * Search.Rexx, a search function for Cd-Roms
  3.  * that are configured for use with MegaCD ⌐ David Huckett 1995
  4.  * This program can only be called by MegaCD and resides in the
  5.  * same directory as MegaCD..
  6. */
  7.  
  8. /* Search.rexx v1.01   Xenolink 1.95 CD-Rom Door.
  9.  *   By David Huckett  12-Sep-95 3:640/800 Fido
  10. */
  11.  
  12. FILEDIR   = 'Doors:MegaCD/'        /* Where this util is, Filelists   */
  13.                     /* are written and your header file*/
  14.                     /* is located..                    */
  15. CDCFG     = 'Doors:MegaCD/CD.cfg'
  16. SEARCHPATH= 'Doors:MegaCD/Search/'
  17.  
  18. /************** PLEASE DO NOT CHANGE ANYTHING BELOW HERE *************/
  19.  
  20. LHA = 'ED'x; DMS = 'E0'x; LZH = 'E1'x; TXT = 'E2'x; DOC = 'E3'x; MOD = 'E4'x
  21. ZIP = 'E5'x; ZOO = 'E6'x; ARC = 'E7'x; EXE = 'E8'x; LZX = 'E9'x; ARJ = 'EA'x
  22. GIF = 'EB'x; TIF = 'EC'x; BMP = 'EE'x; JPG = 'EF'x; PCX = 'F0'x
  23.  
  24. options results
  25. PR = 'PRINT'
  26.  
  27. arg Node_Number CDName ConfigCD
  28. host = 'XenolinkRexxPort'Node_Number
  29. address value host
  30. signal on error
  31. signal on syntax
  32. signal on IOERR
  33.  
  34.  if ~show('L','rexxsupport.library') then do
  35.   if ~addlib('rexxsupport.library',0,-30,0) then do
  36.     PR 'Support library not available.'
  37.      call error
  38.     signal Quit
  39.    end
  40. end
  41. Allfiles = '0'
  42. CALL PRAGMA('W','N')  /* Disk Requesters OFF */
  43.  
  44. MAIN:
  45.  
  46. wild = ''
  47. pr 'Wildcards are allowed in the following formats only..:'
  48. pr '*foo.lha , foo* , *foo* .. any others and file will not be found.'
  49. pr
  50. prompt 25 normal 'Enter the full name to search for: '
  51. find1 = strip(result)
  52. find = find1
  53. if index(find,'*')= 0 then do;wild='NO';find =upper(find);end 
  54. if index(find,'*')= 1 then do;wild ='F';find = substr(upper(find),2);end
  55. if index(find,'*')> 1 then do;if wild ='F' then wild='FR';else wild ='R';ln=length(find)-1;find=upper(substr(find,1,ln));end
  56. find2 = find
  57. NoExt = 0
  58. extens = right(find,4)
  59.             SELECT
  60.  
  61.     When extens = '.LHA' then find = left(find,(length(find)-4))||upper(LHA)
  62.     When extens = '.ZIP' then find = left(find,(length(find)-4))||upper(ZIP)
  63.     When extens = '.DMS' then find = left(find,(length(find)-4))||upper(DMS)
  64.     When extens = '.MOD' then find = left(find,(length(find)-4))||upper(MOD)
  65.     When extens = '.LZH' then find = left(find,(length(find)-4))||upper(LZH)
  66.     When extens = '.TXT' then find = left(find,(length(find)-4))||upper(TXT)
  67.     When extens = '.EXE' then find = left(find,(length(find)-4))||upper(EXE)
  68.     When extens = '.JPG' then find = left(find,(length(find)-4))||upper(JPG)
  69.     When extens = '.GIF' then find = left(find,(length(find)-4))||upper(GIF)
  70.  
  71.             OTHERWISE NoExt = 1
  72. end
  73.  
  74. IndTIT = CDName
  75. If ~exists(SearchPath||IndTIT||'.dex') then do
  76. pr
  77. pr 'Cant find an Search index file for that CD-Rom...'
  78. pr 'Ask the sysop to create one...'
  79. msg 'Any key to continue...'
  80. getchar
  81. Exit 0
  82. end
  83. cls
  84. pr
  85. pr 'Searching for file : 'find2 'and 'find
  86. if wild = 'NO' then do
  87. if NoExt = 0 then find = left(find,(length(find)-1))
  88. end
  89. call open(fllist,SearchPath||IndTIT||'.dex','R')
  90.     Findpath = Readln(fllist)
  91.     do l =1 While ~EOF(fllist)
  92. msg '.'
  93.     findln.l = Readln(fllist)
  94.     findln.l = Upper(findln.l)
  95.     t= index(findln.l,find)
  96.     if t ~= 0 then do
  97.  
  98.  
  99.         Pr
  100.         Pr 'Matching File Found...'
  101.         msg 'Locating description..'
  102. fnd = 0
  103. configCD = strip(configCD)
  104.         call open(ccfg,configCD, 'R')
  105.         cdpathname  = readln(ccfg)
  106.         indexpath   = readln(ccfg)
  107.         displayfile = readln(ccfg)
  108.         skipstart   = readln(ccfg)
  109.  
  110.         do j = 1 to value(word(findln.l,1))
  111.         directory    = word(readln(ccfg),1)
  112.         end
  113.         call close(ccfg)
  114. txtfile = Indexpath||directory||displayfile
  115. call open(list,txtfile,'R')
  116.     do g = 1 to skipstart
  117.     junk.g = readln(list)
  118.     end
  119.     do g =1 While ~EOF(list)
  120. msg '.'
  121.     filname = Readln(list)
  122.     if index(upper(word(filname,1)),find2) ~=0 then do
  123.         fulfile = word(filname,1)
  124.         descp   = subword(filname,2)
  125.         call close(list)
  126.         fnd = 1
  127.         leave g        
  128.         end
  129.     end
  130. if fnd ~= 1 then do
  131.         descp = 'No description found'
  132.         fulfile = find2
  133.         call close(list)
  134.     end
  135.  
  136.         pr
  137.         pr 'Found :'left(fulfile,20)||descp
  138.         pr
  139.         QueryYN 'Do you wish to mark file for download? '
  140.         reply = upper(result)
  141.         if reply = 'Y' then do;call close(fllist);signal Download;end
  142.         if reply = 'N' then do
  143.             QueryNY 'Continue search? '
  144.             reply = upper(result)
  145.             if reply = 'N' then do;call close(fllist);Exit 0;end
  146.             if reply = 'Y' then NOP
  147.             end
  148.         end
  149. end
  150.  
  151. call close(fllist)
  152. pr
  153. pr 'File not found..'
  154. getchar
  155. Exit 0
  156.  
  157.  
  158. DOWNLOAD:
  159. pr
  160. Pr 'Adding 'fulfile' to download list...'
  161. call delay 100
  162. filepaths = findpath||directory
  163. MarkedFile = fulfile
  164. if ~exists('T:MRXDL'node_Number'.sfl') Then do
  165.     call open(tempdl,'T:MRXDL'node_Number'.sfl','W')
  166.     Call WriteLn(Tempdl,filepaths word(MarkedFile,1))
  167.     Call Close(Tempdl)
  168. end
  169. else do
  170.     Call open(Tempdl,'T:MRXDL'node_Number'.sfl','A')
  171.     Call WriteLN(tempdl,filepaths word(MarkedFile,1))
  172.     Call Close(tempdl)
  173. end
  174.  
  175.  
  176. Exit 0
  177.  
  178.  
  179.  
  180. QUIT:
  181. Exit 0
  182.  
  183. error:
  184. a = SIGL;message 'Error!!!  Line # 'a;call delay 200
  185. EXIT 10
  186.  
  187. syntax:
  188. a = SIGL;message 'Syntax Error!!!  Line # 'a;call delay 200
  189. EXIT 10
  190.  
  191. ioerr:
  192. message 'I/O Error!!!';call delay 200
  193. EXIT 10
  194.